<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.tueye.entity.user.User"%>
<%@page import="com.tueye.utils.TuEyeConstant"%>
<%@ taglib prefix="c"       uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 User loginuser =  (User) session.getAttribute(TuEyeConstant.TUEYE_USER);
 
  if(loginuser  == null){
     request.getRequestDispatcher("userlogin.jsp").forward(request,response);
 }
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
     <meta http-equiv="content-Type" content="text/html; charset=utf-8" />
    <title>用户信息设置</title>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<meta http-equiv="keywords" content="blog,图片,david" />
	<meta http-equiv="description" content="This is my web blog" />
	
<link href="<%=path %>/themes/css/index.css" rel="stylesheet" type="text/css" />
<link href="<%=path %>/themes/css/pmanager.css" rel="stylesheet" type="text/css" />

   <script type="text/javascript" src="<%=path %>/script/jquery.js"></script>
 <script type="text/javascript" src="<%=path %>/script/jquery.jSelectDate.js"></script>
<style type="text/css">
.warning{

}
.code{
  font-size:12px;
}
span.date select{ margin-bottom:2px;}

</style>
<script type="text/javascript">
			
			$("body").ready(function(){
			
				var birthday = $('#birthday_more').val();
                var b = birthday.substr(0,10);
                $('#txtName').attr("value",b);
               
				//应用方法
				$("input.date").jSelectDate({
					css:"date",
					yearBeign: 1995,
					disabled : false,
					showLabel : false
				});

			})
			
			$(this).jSelectDate

		</script>		
<script type="text/javascript">

 $(function(){ 
 //判断性别的选中
		 var sex =  $('#sex_more').val();
 		if(sex==1){
		 $('#sex1').attr("checked","true"); 
 		}
 		if(sex==2){
 		$('#sex2').attr("checked","true"); 
 		}
 //判断体型的选中
		var tixing = $('#tixing_more').val();
		if(tixing==null||tixing==''){
		$("#TiXing").attr("value",'1');
		}else{
		$("#TiXing").attr("value",tixing);
		}
//判断恋爱情况
		var love = $('#loveType_more').val();
		if(love==null||love==''){
		$("#sex").attr("value",'0');
		}
		if(love==1){
 		$('#love1').attr("checked","true"); 
 		}
 		if(love==2){
 		$('#love2').attr("checked","true"); 
 		}
 		if(love==3){
 		$('#love3').attr("checked","true"); 
 		}


  $('form :input').blur(function(){
	         var id = $(this).attr("id");
             $(this).removeClass("warning").parents("td")
			 .find("span.error").remove()
			 .end()
			 .find("span.ok").remove();

		     var $listItem =  $(this).parents("td").find("span:last");
 
           //验证msn
			 if( id == 'msn' ){
		
				if(!/.+@.+\.[a-zA-Z]{2,4}$/.test($(this).attr("value"))){
				   
				      if($(this).attr("value") == null || $(this).attr("value") == ''){
				      var okMsg = '';
                      $(this).parent().next().text(okMsg)
				      }else{
                      var errorMsg = '请输入有效的msn!';
					  $('<span class="error"></span>').css("color","red")
					  $(this).parent().next().text(errorMsg)
					  .appendTo($listItem);
					 
					  $(this).addClass("warning");
					  }
				}	else{
				      var okMsg = '';
                      $(this).parent().next().text(okMsg)
				}
				}
			//验证是网址
			if( id == 'userWebSite' ){
		
				if(!/^[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/.test($(this).attr("value"))){
				   
				      if($(this).attr("value") == null || $(this).attr("value") == ''){
				      var okMsg = '';
                      $(this).parent().next().text(okMsg)
				      }else{
                      var errorMsg = '请输入有效的网址!';
					  $('<span class="error"></span>').css("color","red")
					  $(this).parent().next().text(errorMsg)
					  .appendTo($listItem);
					 
					  $(this).addClass("warning");
					  }
				}	else{
				      var okMsg = '';
                      $(this).parent().next().text(okMsg)
				}
				}
				//判断qq格式
				if( id == 'qq' ){
		
				if(!/^[1-9][0-9]{0,10}(,[1-9][0-9]{0,10}){0,10}$/.test($(this).attr("value"))){
				   
				      if($(this).attr("value") == null || $(this).attr("value") == ''){
				      var okMsg = '';
                      $(this).parent().next().text(okMsg)
				      }else{
                      var errorMsg = '请输入有效的qq!';
					  $('<span class="error"></span>').css("color","red")
					  $(this).parent().next().text(errorMsg)
					  .appendTo($listItem);
					 
					  $(this).addClass("warning");
					  }
				}	else{
				      if($(this).attr("value").length>4){
				      var okMsg = '';
                      $(this).parent().next().text(okMsg)
                      }else{
                       var errorMsg = '请输入有效的qq!';
					  $('<span class="error"></span>').css("color","red")
					  $(this).parent().next().text(errorMsg)
					  .appendTo($listItem);
					 
					  $(this).addClass("warning");
                      }
				}
				}
		        
		      })
 
		$("#tijiao").bind("click", function(){
		
		$(":input").trigger('blur');
		
			var numWarning = $('.warning',$('form')).length;
			
            if(numWarning){
			    var errorFieldList = [];
                $(".warning").each(function(){
					errorFieldList.push( $(this).prev("span").text() );
				})
				
				return false;
			}  
			var id = $('#id').val();
			
			if($('input[@name=sex][@checked]').val()==undefined) {
			var sex = '0';
			}else{
			var sex = $('input[@name=sex][@checked]').val();
			}
			var TiXing =  $('#TiXing').val();
			if($('input[@name=loveType][@checked]').val()==undefined) {
			var loveType = '0';
			}else{
			var loveType = $('input[@name=loveType][@checked]').val();
			}
			var birthday =  $('#txtName').val();
			var star_type =  $('#star_type').val();
			var qq =  $('#qq').val();
			var msn = $('#msn').val();
			var workType =  $('#workType').val();
			var over_school =  $('#over_school').val();
			var userWebSite =  $('#userWebSite').val();
			var loveThings =  $('#loveThings').text();
			var movierAuthor =  $('#movierAuthor').text();
			var music =  $('#music').text();
			var sendData="sex="+sex+"&TiXing="+TiXing+"&loveType="+loveType+"&birthday="+birthday+"&id="+id+"&star_type="+encodeURIComponent(star_type)+
			"&qq="+qq+"&msn="+msn+"&workType="+encodeURIComponent(workType)+"&over_school="+encodeURIComponent(over_school)+
			"&userWebSite="+encodeURIComponent(userWebSite)+"&music="+encodeURIComponent(music)+
			"&loveThings="+encodeURIComponent(loveThings)+"&movierAuthor="+encodeURIComponent(movierAuthor);
	
			$.ajax({
            type:"POST",
            url: "<%=request.getContextPath()%>/updateMoreUserinfo.do", 
            dataType:'html', //接受数据格式
            async: false,
            data: sendData,

            success: function(data){ 
           
                    $("#loadtip2").show();  
                 
                },
           error:function(data){
             alert(data);
           }
            }) 
      });
       }) 
	function refrash(){
		$('#imgId')[0].src+='?'+Math.floor(Math.random()*10);
		}
		
	function getAstro(month,day){    
    	var s="魔羯座水瓶座双鱼座牡羊座金牛座双子座巨蟹座狮子座处女座天秤座天蝎座射手座魔羯座";
    	var arr=[20,19,21,21,21,22,23,23,23,23,22,22];
    	return s.substr(month*3-(day<arr[month-1]?3:0),3);
	}


	function change(){    
   //判断星座
 	var xingzuo =  $('#txtName').val();  //2003-03-01
 	var m1 = xingzuo.substr(5,2);
 	var m1_1 = m1.substr(1,1);
 	if (m1_1=="-"){
 	var month = m1.substr(0,1);
 	var d1 = xingzuo.substr(7,2);
 	var day = d1;
 	}else{
 	    var month = m1;
 	    var d1 = xingzuo.substr(8,2);
   		var day = d1;
	 }
	    var xz = getAstro(month,day);
 	    $('#star_type').attr("value",xz);
	}
</script>
</head>

<body>
   <%@ include file="../../../../common/header.jsp" %>
<div id="container">
<div id="mainbody">
  <div id="managerleftbody">
     <h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;我的设置</h2>
	  <ul>
	    <li class="lefttitle">信息设置</li>
	   <li><a href="<%=request.getContextPath()%>/userinfoset.do">基本信息</a></li>
	   <li><a href="<%=request.getContextPath()%>/pages/topics/usermanager/updateUserface.jsp">更换头像</a></li>
	   <li>详细信息</li>
		 <li><a href="<%=request.getContextPath()%>/useraccount.do">帐户设置</a></li> 
	  </ul>
	  
	  <ul>
	    <li class="lefttitle">作品管理</li>
	   <li><a href="<%=request.getContextPath()%>/usertopicmanager.do">发布的作品</a></li>
	   <li><a href="<%=request.getContextPath()%>/usercollect.do">收藏的作品</a></li>
	   <li><a href="<%=request.getContextPath()%>/usercomment.do">评论的作品</a></li> 
	  </ul>
	   <ul>
	    <li class="lefttitle">站内动态</li>
	   <li><a href="javascript:alert('功能暂未启用')">全站动态</a></li>
		 <li><a href="javascript:alert('功能暂未启用')">我的好友</a></li>
	   <li><a href="javascript:alert('功能暂未启用')">好友动态</a></li>
	    
	  </ul>
  </div>
   <div id="managerrightbody">
	   <div class="ClassTitle">基本信息设置</div>
	   <form method="post" action="">
		<table>
		 <tr><td>
	 <div style="display:none;" id="loadtip2"><img src="<%=path%>/themes/images/success.gif"　width="30px" height="20px"/><font color="red">详细信息设置成功</font></div> 
	 </td></tr>
		  <tr>
		  <input type="hidden" id= "id" value="${pu.id}"/>
		  <input type="hidden" id= "sex_more" value="${pu.sex}"/>
		   <input type="hidden" id= "tixing_more" value="${pu.tiXing}"/>
		   <td>性别:</td><td><input type="radio" id = "sex1" value="1" name="sex"/>男<input type="radio" id = "sex2" value="2" name="sex"/>女</td><td class="regtip"></td>
		  </tr>
		  <tr>	 
		   <td>体型:</td><td>  <select name="TiXing" id="TiXing"><option value="1">保密</option>
		   <option value="2">清瘦</option>
		   <option value="3">均称</option>
		   <option value="4">健壮</option>
		   <option value="5">球型</option>	   
		   </select>
		   </td><td class="regtip"></td>
		  </tr>
		   <tr>
		  <input type="hidden" id= "loveType_more" value="${pu.loveType}"/>
		   <td>恋爱情况:</td><td><input type="radio" id = "love1" value="1" name="loveType"/>单身<input type="radio" id = "love2" value="2" name="loveType"/>热恋<input type="radio" id = "love3" value="3" name="loveType"/>已婚</td><td class="regtip"></td>
		  </tr>
		   <tr>
		   <input type="hidden" id= "birthday_more" value="${pu.birthday}"/>
		   <td>生日:</td><td><input type="text" id="txtName" class="date" value="" />
          </td>
		  </tr>
		   <tr>
		   <td>星座:</td><td><input type="text" name="star_type" id="star_type" value="${pu.star_type}" onclick="change()"/></td>
		  </tr>
		  <tr>
		   <td>QQ：</td><td><input type="text" name="qq" id="qq" value="${pu.qq}"  /></td><td class="regtip"></td>
		  </tr>
		  <tr>
		   <td>MSN:</td><td><input type="text" name="msn" id="msn" value="${pu.msn}"/></td><td class="regtip"></td>
		  </tr>
		  <tr>
		   <td>行业 / 职业:</td><td><input type="text" name="workType" id="workType" value="${pu.workType}"  /></td>
		  </tr>
		  <tr>
		   <td>毕业学校：</td><td><input type="text" name="over_school" id="over_school" value="${pu.over_school}"  /></td>
		  </tr>
		  <tr>
		   <td>个人主页：</td><td>http://<input type="text" name="userWebSite" id="userWebSite" value="${pu.userWebSite}"  /></td><td class="regtip"></td>
		  </tr>
		  <tr>
		   <td>爱好:</td><td><textarea   name="loveThings" id="loveThings" cols="30" rows="6" >${pu.loveThings}</textarea>
        </td>
		  </tr>
		  <tr>
		   <td>电影 / 导演 / 演员：</td><td><textarea   name="movierAuthor" id="movierAuthor" cols="30" rows="6" >${pu.movierAuthor}</textarea>
        </td>
		  </tr>
		  <tr>
		   <td>音乐 / 歌曲 / 歌手：</td><td><textarea   name="music" id="music" cols="30" rows="6" >${pu.music}</textarea>
        </td>
		  </tr>
		 
		  <tr>
		   <td  colspan="2" align="center"><br /><input type="button"  id="tijiao" value="提交" /></td>
		  </tr>
		</table>
		</form>
	</div>
 </div>
 </div>

<div id="tailer">

<div id="aboutUs">
<ul>
<li><a href="#">关于tueye</a></li>
<li><a href="#">广告服务</a></li>
<li><a href="#">合作伙伴</a></li>
<li><a href="#">帮助中心</a></li>
</ul>
</div>
<div id="copyRight">Copyright 2003-2008, 版权所有 TUEYE.COM</div>
</div>
</body>
</html>

